<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>骡窝窝系统管理平台</title>
    <#include "../common/header.ftl"/>
    <script type="text/javascript" src="/js/plugins/My97DatePicker/WdatePicker.js"></script>

    <script type="text/javascript">
        $(function () {
            $("#pagination").twbsPagination({
                totalPages:${pageInfo.pages}|| 1,
                    visiblePages
        :
            5,
                    startPage
        :${qo.currentPage},
            first:"首页",
                    prev
        :
            "上一页",
                    next
        :
            "下一页",
                    last
        :
            "尾页",
                    onPageClick
        :

            function (event, page) {
                $("#currentPage").val(page);
                $("#searchForm").submit();
            }
        })
            ;

            //分页
            $("#query").click(function () {
                $("#currentPage").val(1);
                $("#searchForm").submit();
            });


            //点击修改按钮
            $(".inputBtn").click(function () {
                // 4步走,清空,取值,回显,显示
                // 1. 清空
                $('#inputModal input').val('');
                $('#inputModal select').val('');
                // 2. 取值
                var obj = $(this).data('json');

                // 3. 编辑回显
                if (obj) {
                    $('#inputModal input[name="id"]').val(obj.id);
                    $('#inputModal input[name="name"]').val(obj.name);
                    $('#inputModal input[name="phone"]').val(obj.phone);
                    $('#inputModal input[name="address"]').val(obj.address);
                    $('#inputModal input[name="cost"]').val(obj.cost);
                    $('#inputModal select[name="status"]').val(obj.status);

                }
                // 4. 显示
                $('#inputModal').modal('show');


            });

            $("#saveBtn").click(function () {
                $("#editForm").ajaxSubmit(function (data) {
                    if (data.success){
                        location.reload();
                    }else{
                        alert(data.msg);
                    }
                })
            })



        });
    </script>
    <style type="text/css">
        .modal-body {
            height: 500px;
            overflow: scroll;
        }
    </style>
</head>

<body>

<div class="container">
<#include "../common/top.ftl"/>
    <div class="row">
        <div class="col-sm-3">
        <#assign currentMenu = "order" />
				<#include "../common/menu.ftl" />
        </div>
        <div class="col-sm-9">
            <div class="page-header">
                <h3>订单管理</h3>
            </div>
            <div class="row">
                <!-- 提交分页的表单 -->
                <form id="searchForm" class="form-inline" method="post" action="/order/list.do">
                    <input type="hidden" name="currentPage" id="currentPage" value="1"/>
                    <div class="form-group">
                        <label>关键字</label>
                        <input class="form-control" type="text" name="keyword" value="${(qo.keyword)!''}">
                    </div>
                    <div class="form-group">
                        <select class="form-control" id="status" name="status" autocomplete="off">
                            <option value="">全部状态</option>
                            <option value="0">待付款</option>
                            <option value="1">待收货</option>
                            <option value="2">已完成</option>
                            <option value="3">已取消</option>
                        </select>
                    <script type="application/javascript">$('#status').val(${(qo.status)!})</script>
                    </div>
                    <div class="form-group">
                        <button id="query" type="button" class="btn btn-success"><i class="icon-search"></i> 查询</button>
                    </div>
                </form>
            </div>
            <div class="row">
                <table class="table">
                    <thead>
                    <tr>
                        <th>订单号</th>
                        <th>用户名</th>
                        <th>下单时间</th>
                        <th>地区</th>
                        <th>价格</th>
                        <th>电话</th>
                        <th>状态</th>
                        <th></th>
                    </tr>
                    </thead>
                    <tbody>
					<#list pageInfo.list as vo>
                    <tr>
                        <td>${vo.orderNumber}</td>
                        <td>${vo.name}</td>
                        <td>${vo.createTime?string('yyyy-MM-dd hh:mm:ss')}</td>
                        <td>${vo.address}</td>
                        <td>${vo.cost}</td>
                        <td>${vo.phone}</td>

                        <td>
                            <#if vo.status == 1>
                                待收货
                            <#elseif vo.status == 2>
                                已完成
                            <#elseif vo.status == 3>
                                已取消
                            <#elseif vo.status == 0>
                                待付款
                            </#if>
                        </td>
                        <td>
                            <a href="javascript:" class="btn btn-sm btn-success inputBtn" data-json='${vo.json}'>
                                <span class="glyphicon glyphicon-edit "></span> 修改
                            </a>
                        </td>
                    </tr>
                    </#list>
                    </tbody>
                </table>

                <div style="text-align: center;">
                    <ul id="pagination" class="pagination"></ul>
                </div>
            </div>
        </div>
    </div>
</div>


<div id="inputModal" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">编辑/增加</h4>
            </div>
            <div class="modal-body">
                <form id="editForm" class="form-horizontal" method="post" action="/order/UpdateOrder.do">
                <input type="hidden" name="id">
                <div class="form-group">
                    <label class="col-sm-3 control-label">收货人</label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" id="productName" name="name" placeholder="名称">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">电话</label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" id="price" name="phone" placeholder="电话">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">地区</label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" id="price" name="address" placeholder="地区">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">价格</label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" id="price" name="cost" placeholder="价格">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">状态</label>
                    <div class="col-sm-7">
                        <select id="status" class="form-control" autocomplete="off" name="status">
                            <option value="0">待付款</option>
                            <option value="1">待收货</option>
                            <option value="2">已完成</option>
                            <option value="3">已取消</option>
                        </select>
                    </div>
                </div>
                </form>
            </div>
            <div class="modal-footer">
                <a href="javascript:void(0);" class="btn btn-success" id="saveBtn" aria-hidden="true">保存</a>
                <a href="javascript:void(0);" class="btn" data-dismiss="modal" aria-hidden="true">关闭</a>
            </div>
        </div>
    </div>
</div>



</body>
</html>